var crypto = require('crypto');


export function isPromise(value) {
  if (value !== null && typeof value === 'object') {
    return value.promise && typeof value.promise.then === 'function';
  }
}

export function getCookie(name) {
  var value = "; " + document.cookie;
  var parts = value.split("; " + name + "=");
  if (parts.length == 2) return parts.pop().split(";").shift();
}
export function format(date){
  var year=date.getFullYear();
  var month=date.getMonth()+1<10 ? '0'+(date.getMonth()+1):(date.getMonth()+1);
  var day=date.getDate();
  var hours=date.getHours();
  var minutes=date.getMinutes()<10 ? '0'+date.getMinutes() : date.getMinutes();
  var seconds=date.getSeconds()<10 ? '0'+date.getSeconds() :date.getSeconds();
  var time=year+'-'+month+'-'+day+" "+hours+":"+minutes+":"+seconds;
  return time
}
export function getNowTime(){
  var now=new Date();

  return  format(now);
}

export function   timeStampToDate(now)   {
  return format(now)
}

//////////////////////////////
// salt算法
//////////////////////////////
export function Encrypt(value,salt){

  var crypto = require('crypto');
  var md5 = crypto.createHash('md5');
  var encrypt= md5.update(value+salt).digest('hex');
  return  encrypt
}




